package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.AddressBook;
import com.itheima.reggie.mapper.AddressBookMapper;
import com.itheima.reggie.service.AddressBookService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressBookServiceImpl extends ServiceImpl<AddressBookMapper, AddressBook> implements AddressBookService {
    /**
     * 修改地址
     *
     * @param addressBook
     * @return String
     */

    @Override
    public R<String> updateAddress(AddressBook addressBook) {
        this.updateById(addressBook);
        return R.success("成功！");
    }

    /**
     * 删除地址
     *
     * @param ids
     * @return
     */

    @Override
    public R<String> deleteAddress(List<Long> ids) {
        if (ObjectUtils.isEmpty(ids)) {
            return R.error("参数错误！");
        }
        this.removeByIds(ids);
        return R.success("成功！");
    }
}